// TypeScript file
class SpecialNumber extends egret.Sprite
{
    private charName: string;
    constructor(str: string)
    {
        super();
        this.charName = str;
    }

    public setValue(num: string): void
    {
        this.removeChildren();
        if (num == "" || num == null) return;

        let chars: Array<any> = (num + "").split("");
        let len: number = chars.length;
        let ww:number = 0;
        let imageName: string;
        if (this.charName == "number-")
        {
            imageName = "sourceNum_json";
        }
        else if (this.charName == "number-0")
        {
            imageName = "streakNum_json";
        }
        for (let i: number = 0; i < len; ++i)
        {
            let str: string = chars[i];
            switch (str)
            {
                case ",":
                {
                    str = "dot";
                }
                break;
                case "/":
                {
                    str = "gang";
                }
                break;
            }

            let image: egret.Bitmap = ResourceUtils.createBitmapFromSheet(this.charName+str, imageName);

            if (image)
            {
                image.x = ww;
                ww += image.width;
                this.addChild(image);
            }
        }

    }
}